/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ua.i.kotionokyurievna.jewelry.domain.product;

import java.util.ArrayList;
import java.util.List;
import ua.i.kotionokyurievna.jewelry.domain.productwork.ProductWork;

/**
 *
 * @author Kateryna_Reznik
 */
public class Product {
    private int productId;
    private ProductType productType;
    private boolean inCatalogue;
    private String specification;
    private List<ProductWork> works;
 
    public Product() {
    }

    public Product(ProductType productType, boolean inCatalogue,
            String specification) {
        this.productType = productType;
        this.inCatalogue = inCatalogue;
        this.specification = specification;
        this.works = new ArrayList<ProductWork>();
    }
    
    public Product( ProductType productType, boolean inCatalogue, 
            String specification, List<ProductWork> works) {
        this.productType = productType;
        this.inCatalogue = inCatalogue;
        this.specification = specification;
        this.works = new ArrayList<ProductWork>();
    }
    
    public Product(int productId, ProductType productType, boolean inCatalogue, 
            String specification) {
        this.productId = productId;
        this.productType = productType;
        this.inCatalogue = inCatalogue;
        this.specification = specification;
        this.works = new ArrayList<ProductWork>();
    }

    public Product(int productId, ProductType productType, boolean inCatalogue, 
            String specification, List<ProductWork> works) {
        this.productType = productType;
        this.inCatalogue = inCatalogue;
        this.specification = specification;
        this.works = new ArrayList<ProductWork>();
        for ( ProductWork work: works){
                this.works.add(work);
        }
    }
       
    public Product( Product product ){
        if ( product != null ){
            this.productId = product.productId;
            this.productType = product.productType;
            this.inCatalogue = product.inCatalogue;
            this.specification = product.specification;
            this.works = new ArrayList<ProductWork>();
            for ( ProductWork work: works){
                this.works.add(work);
            }
        }
    }

    public int getProductId() {
        return productId;
    }

    public ProductType getProductType() {
        return productType;
    }

    public void setProductType(ProductType productType) {
        this.productType = productType;
    }

    public boolean isInCatalogue() {
        return inCatalogue;
    }

    public void setInCatalogue(boolean inCatalogue) {
        this.inCatalogue = inCatalogue;
    }

    public String getSpecification() {
        return specification;
    }

    public void setSpecification(String specification) {
        this.specification = specification;
    }

    public List<ProductWork> getWorks() {
        return works;
    }

    public void setWorks(List<ProductWork> works) {
        this.works = works;
    }

    @Override
    public String toString() {
        return "Product{" + "productId=" + productId + ", productType=" + 
                productType + ", inCatalogue=" + inCatalogue + 
                ", specification=" + specification + ", works=" + works + '}';
    }
    
    

    @Override
    public int hashCode() {
        int hash = 5;
        hash = 37 * hash + (this.productType != null ?
                this.productType.hashCode() : 0);
        hash = 37 * hash + (this.inCatalogue ? 1 : 0);
        hash = 37 * hash + (this.specification != null ? 
                this.specification.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Product other = (Product) obj;
        if (this.productType != other.productType) {
            return false;
        }
        if (this.inCatalogue != other.inCatalogue) {
            return false;
        }
        if ((this.specification == null) ? (other.specification != null) : 
                !this.specification.equals(other.specification)) {
            return false;
        }
        return true;
    }
    
    
}
